package org.example.backend.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

@Configuration
public class SwaggerConfig {
    
    @Value("${server.servlet.context-path}")
    private String contextPath;
    
    @Value("${server.port}")
    private String port;
    
    @Bean
    public OpenAPI openAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("天气主服务API文档")
                        .description("天气主服务API接口文档")
                        .version("1.0.0")
                        .contact(new Contact()
                                .name("开发者")
                                .email("dev@example.org"))
                        .license(new License().name("Apache 2.0")))
                .servers(Arrays.asList(
                        new Server().url("http://localhost:" + port + contextPath).description("本地服务器")
                ));
    }
} 